<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn" xml:lang="zh-cn">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="DC.Type" content="topic">
  <meta name="DC.Title" content="添加源端重删用户到sudoers（适用于Linux OS）">
  <meta name="DC.Format" content="XHTML">
  <meta name="DC.Identifier" content="ZH-CN_TOPIC_0000001792390228">
  <meta name="DC.Language" content="zh-cn">
  <link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
  <title>添加源端重删用户到sudoers（适用于Linux OS）</title>
 </head>
 <body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px">
  <a name="ZH-CN_TOPIC_0000001792390228"></a><a name="ZH-CN_TOPIC_0000001792390228"></a>
  <h1 class="topictitle1">添加源端重删用户到sudoers（适用于Linux OS）</h1>
  <div id="body8662426">
   <p id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_p183483913313">通过自动推送方式安装ProtectAgent时，<span class="uicontrol" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_uicontrol109791574319">“用户类型”</span>配置为<span class="uicontrol" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_uicontrol139797571032">“超级管理员”</span>，且需开启源端重删功能时，请在首次备份前，执行本节操作将源端重删用户加到sudoers中。本章节以EulerOS为例进行说明。</p>
   <div class="section" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_section175941115163111">
    <h4 class="sectiontitle">操作步骤</h4>
    <ol id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_ol122521212317">
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li12252102115312"><span>使用<strong id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_b853116173134">root</strong>账户登录代理主机。</span></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1296882714311"><span>执行以下命令，查找sudoers配置文件的目录。</span><p></p><pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen2925152217527">whereis sudoers</pre> <p id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_p82051743122320">回显类似如下，其中“/etc/sudoers”为sudoers配置文件的目录。</p> <pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen203173536238">sudoers: <strong id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_b18409559152516">/etc/sudoers</strong> /etc/sudoers.d /uer/share/man/man5/sudoers.5.gz</pre> <p></p></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li963520185474"><span>执行以下命令，查询sudoers配置文件权限。</span><p></p><pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen2061215122712">ll /etc/sudoers</pre> <p id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_p1395722592712">回显类似如下，表示<strong id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_b622024964019">root</strong>用户仅有sudoers配置文件的只读权限，则请执行<a href="#ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1967213198527">4</a>为<strong id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_b1831894716414">root</strong>用户添加该配置文件的可写权限。如已有该配置文件的可写权限，则直接执行<a href="#ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1783801718592">5</a>。</p> <pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen5894174019277">-r--r-----. 1 root root 20724 Nov 19 21:04 /etc/sudoers</pre> <p></p></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1967213198527"><a name="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1967213198527"></a><a name="zh-cn_topic_0000001608686382_li1967213198527"></a><span>执行以下命令，修改sudoers配置文件权限。</span><p></p><pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen2141552105214">chmod u+w /etc/sudoers</pre> <p></p></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1783801718592"><a name="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1783801718592"></a><a name="zh-cn_topic_0000001608686382_li1783801718592"></a><span>执行以下命令，备份源文件。</span><p></p><pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen205131331105917">mkdir /etc/backup_sudoers</pre> <pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen21174444479">cp /etc/sudoers /etc/backup_sudoers</pre> <p></p></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li4145165012521"><a name="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li4145165012521"></a><a name="zh-cn_topic_0000001608686382_li4145165012521"></a><span>执行以下命令，打开sudoers配置文件。</span><p></p><pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen92963290535">vim /etc/sudoers</pre> <p></p></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li994215063110"><span>如果配置文件中存在<span class="parmname" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_parmname10174344172510">“Defaults requiretty”</span>字段，请执行本步骤。否则，结束本章节操作。</span><p></p>
      <div class="notice" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_note174109293718">
       <span class="noticetitle"><img src="public_sys-resources/notice_3.0-zh-cn.png"> </span>
       <div class="noticebody">
        <p id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_p84110291713">请严格按照以下要求修改配置文件，否则可能导致源端重删功能不可用或sudo命令执行失败。</p>
       </div>
      </div>
      <ul id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_ul1075815385454">
       <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li47581238144518">方式一：删除<span class="parmname" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_parmname13796151318468">“Defaults requiretty”</span>字段。</li>
       <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li3953715144612">方式二：添加源端重删用户到sudoers中。
        <ul id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_ul1930163133910">
         <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li322843014419">如果需进行VMware的源端重删，需要将VMware的DataTurbo用户（用户名为：<strong id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_b1929114297538">VMDataTurbo</strong>）添加到配置文件中。<pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen17383131323011">Defaults:VMDataTurbo !requiretty</pre></li>
         <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li13228230164411">如果需进行其他应用的源端重删，需要将该应用对应的DataTurbo用户（用户名为：<strong id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_b565416217211">data_turbo_account</strong>）添加到配置文件中。<pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen0598122863010">Defaults:data_turbo_account !requiretty</pre></li>
        </ul></li>
      </ul> <p></p></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li11391140173419"><a name="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li11391140173419"></a><a name="zh-cn_topic_0000001608686382_li11391140173419"></a><span>如果执行了<a href="#ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li1967213198527">4</a>修改sudoers配置文件权限，则请执行本步骤，删除sudoers配置文件的可写权限。否则，请跳过本步骤。</span><p></p><pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen27863619358">chmod u-w /etc/sudoers</pre> <p></p></li>
     <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li79011641162019"><span>查看配置文件，确认是否修改成功。</span><p></p><pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen83592506128">cat /etc/sudoers</pre>
      <ul id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_ul1215921062014">
       <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li12370814142619">如果修改失败，请回退配置文件，确认回退成功后，重新执行<a href="#ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li4145165012521">6</a>~<a href="#ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li11391140173419">8</a>。<pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen247405762119">cp /etc/backup_sudoers/sudoers /etc/sudoers
cat /etc/sudoers</pre></li>
       <li id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_li0454155172211">如果修改成功，请删除备份文件。<pre class="screen" id="ZH-CN_TOPIC_0000001792390228__zh-cn_topic_0000001608686382_screen129061154233">rm -fr /etc/backup_sudoers</pre></li>
      </ul> <p></p></li>
    </ol>
   </div>
  </div>
 </body>
</html>